home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 July / EnigmA AMIGA RUN 20 (1997)(G.R. Edizioni)(IT)[!][issue 1997-07 & 08][EAR-CD IV].iso / lightwave / arexx_macros / lwscenemacros / lwobj.rexx < prev    next >
OS/2 REXX Batch file  |  1994-09-05  |  3KB  |  100 lines

  1. /*
  2.    LWObj.rexx
  3.  
  4.    Copyright (C) 1994 Earl C. Terwilliger
  5.                 Phone (606)-723-5718
  6.  
  7.       Internet: AISTERWI@ACS.EKU.EDU
  8.    Conmpuserve: 70575,1330
  9.  
  10.    Non-Commercial USE granted to ALL !!!
  11.  
  12.    LWObj.rexx is a sample Arexx script to read
  13.    a LightWave 3D Object file. It does run OK
  14.    as it is and tells a few things about the
  15.    contents of of the Object file.
  16.  
  17.    It can be further used as a starting point
  18.    ('skeleton') for further enhancement.
  19. */
  20.  
  21. /* TRACE(RESULTS) */
  22. OPTIONS RESULTS
  23.  
  24. parse arg file
  25.  
  26. if arg() = 0     then call syntax()
  27. if ~exists(file) then call syntax()
  28.  
  29. if ~show('L',"rexxsupport.library") then do
  30.     if addlib('rexxsupport.library',0,-30,0) then
  31.         say "Added rexxsupport.library."
  32.     else do
  33.         say "Error: addlib() of rexxsupport.library failed."
  34.         exit 10
  35.     end
  36. end
  37.  
  38. open('infile',file,'R')
  39. instring = readch('infile',12)
  40.  
  41. if (substr(instring,9,4) ~= "LWOB") then do
  42.   close('infile')
  43.   say file' is not a LW Object file!'
  44.   exit(10)
  45. end
  46.  
  47. form   = substr(instring,1,4)
  48. length = c2d(substr(instring,5,4),4)
  49. hex    = c2x(substr(instring,5,4))
  50. type   = substr(instring,9,4)
  51. say file' file 'form' is 'type
  52. length = length + 8
  53. say file 'file size is' length 'bytes' "'"hex"'"'X'
  54.  
  55. do while eof('infile')=0
  56.     instring=readch('infile',8)
  57.     if (eof('infile') = 1) then break
  58.     chunk  = substr(instring,1,4)
  59.     length = c2d(substr(instring,5,4),4)
  60.     hex    = c2x(substr(instring,5,4))
  61.     say 'Chunk Type is' chunk 'with a length of' length 'bytes' "'"hex"'"'X'
  62.     if (chunk =  "PNTS") then do
  63.         points = length / 12
  64.         say "Number of points = " points
  65.     end
  66.     if (chunk = "SURF") then do
  67.         instring = readch('infile',length)
  68.         surfacepos = pos('00'x,instring,1)
  69.         surface  = substr(instring,1,(surfacepos-1))
  70.         surfacepos = surfacepos + (surfacepos // 2) + 1
  71.         say 'Surface Name:' surface
  72.         do while (surfacepos < length)
  73.             subchunk = substr(instring,surfacepos,4)
  74.             say 'Subchunk of ' subchunk
  75.             surfacepos = surfacepos + 4
  76.             len = c2d(substr(instring,surfacepos,2),4)
  77.             surfacepos = surfacepos + 2
  78.             if (subchunk = "TIMG") then do
  79.                 timage = strip(substr(instring,surfacepos,len),'T','00'x)
  80.                 say 'Texture Image ->' timage
  81.             end
  82.             if (subchunk = 'RIMG') then do
  83.                 rimage = strip(substr(instring,surfacepos,len),'T','00'x)
  84.                 say 'Reflection Image ->' rimage
  85.             end
  86.             surfacepos = surfacepos + len
  87.         end
  88.     end
  89.     else seek('infile',length,'C')
  90. end
  91.  
  92. close('infile')
  93. exit 0
  94.  
  95. syntax:
  96. say
  97. say 'Syntax: rx LWOB [drive:directory/]LW-Object-File'
  98. say
  99. exit 10
  100.